package util;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Console 
{
	private static BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
	
	public static void print(Object msg)
	{
		System.out.print(msg);
	}
	
	public static String readLine()
	{
		try
		{
			return reader.readLine();
		}catch(IOException ioe)
		{
			ioe.printStackTrace();
			return null;
		}
	}
	
	public static String readLine(Object message)
	{
		Console.print(message);
		return Console.readLine();
	}
	
	public static Long readLongLine() {
		Long retorno = null;
		do {
			try {
				retorno = Long.parseLong(readLine());
			}catch(Exception e) {
				Console.println("Valor invalido!");
				retorno = null;
			}
		}while(retorno == null);
		
		return retorno;
	}

	public static Long readLongLine(Object message) {
		Console.print(message);
		return Console.readLongLine();
	}
	
	public static Integer readIntegerLine() {
		Integer retorno = null;
		do {
			try {
				retorno = Integer.parseInt(readLine());
			}catch(Exception e) {
				Console.println("Valor invalido!");
				retorno = null;
			}
		}while(retorno == null);
		
		return retorno;
	}
	
	public static Integer readIntegerLine(Object message) {
		Console.print(message);
		return Console.readIntegerLine();
	}

	public static void println(Object value)
	{
		System.out.println(value);
	}	
}
